<script>
export default {
  name: 'ResultBadge',
  functional: true,
  props: {
    result: {
      type: Number,
      required: true,
      validator(value) {
        return [0, 1, 2].indexOf(value) >= 0
      }
    }
  },
  render(h, context) {
    const textMap = {
      0: '未做',
      1: '正确',
      2: '错误'
    }
    const colorMap = {
      0: 'grey400',
      1: 'success',
      2: 'orange'
    }
    const result = context.props.result
    const content = textMap[result] || '未知状态'
    const color = colorMap[result] || 'grey400'
    return h('mu-badge', { props: { content, color } })
  }
}
</script>
